package ZS1;

/**
 * @author xianyu
 * @version 1.0
 * @date 2020/7/24 14:33
 * 汉诺塔问题
 */
public class hanoiProblem {

    public static void main(String[] args) {
        hanoi(3,'A','B','C');
    }


    /*
    * n: 圆盘个数
    * a: 起始点
    * b: 辅助点
    * c: 终点
    * */
    public static void hanoi(int n,char a, char b,char c){
        if(n == 1){
            System.out.println("第" + n + "号盘子：" + a + "-->" + c );
        }else{
            hanoi(n-1,a,c,b);
            System.out.println("第" + n + "号盘子：" + a + "-->" + c );
            hanoi(n-1,b,a,c);
        }
    }

}
